//格式化日期，参数为时间戳
function  FormatDate(date = 0, fmt = 'yyyy-MM-dd hh:mm:ss') {
		date = new Date(+date)
		if (/(y+)/.test(fmt)) {
		  fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
		}
		let o = {
		  'M+': date.getMonth() + 1,
		  'd+': date.getDate(),
		  'h+': date.getHours(),
		  'm+': date.getMinutes(),
		  's+': date.getSeconds()
		};
		for (let k in o) {
		  if (new RegExp(`(${k})`).test(fmt)) {
			let str = o[k] + '';
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
		  }
		}
		return fmt;
}

//日期格式化	
function formatServerDateTime(str,fmt = 'yyyy-MM-dd hh:mm:ss')
{
	
	str = str.replace("/Date(" ,"");
	str = str.replace(")/" ,"");
	
	if(str<0)
	{
		return "--";
	}
	return FormatDate(str,fmt);
}

//格式化服务器的SpanTime时间
function FormatSpanTime(spanTimeObject)
{
	
	var Hours = spanTimeObject.Hours;
	if(Hours<10)
	{
		Hours = "0"+Hours;
	}
	
	var Minutes = spanTimeObject.Minutes;
	
	if(Minutes<10)
	{
		Minutes = "0"+Minutes;
	}
	
	var Seconds = spanTimeObject.Seconds;
	
	if(Seconds<10)
	{
		Seconds = "0"+Seconds;
	}
	
	return  Hours+":"+Minutes+":"+Seconds;
}

///比较不带日期的两个时间大小
function Compare(_startTime,_endTime)
{
	var time=new Date();
	var prefixTime = time.getFullYear() + "/"+(time.getMonth()+1) +"/"+time.getDate();
	var startTime= new Date(Date.parse(prefixTime + " "+_startTime));
	var endTime=new Date(Date.parse(prefixTime + " "+_endTime));
	
	return endTime>startTime;
}


//计算两个时间的间隔分钟，不含日期的当前时间比较
function IntervalMinute(_startTime,_endTime)
   {
	var time=new Date();
	var prefixTime = time.getFullYear() + "/"+(time.getMonth()+1) +"/"+time.getDate();
	var startTime= new Date(Date.parse(prefixTime + " "+_startTime));
	var endTime=new Date(Date.parse(prefixTime + " "+_endTime));
	
	return (endTime.valueOf()-startTime.valueOf())/60000;
   }
   
 //判断时间是否在白天
 function CheckDaysTime(_time)
 {
	 var time=new Date();
	 var prefixTime = time.getFullYear() + "/"+(time.getMonth()+1) +"/"+time.getDate();
	 var startTime= new Date(Date.parse(prefixTime + " "+_time));
	 if(startTime.getHours()<9 || startTime.getHours()>20)
	 {
		 return false;
	 }
	 else
	 {
		 return true;
	 }
 }

